﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="操作XML.aspx.cs" Inherits="Dom操作_操作XML" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <style type="text/css">

 p.MsoNormal
	{margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Times New Roman";
	        margin-left: 0cm;
            margin-right: 0cm;
            margin-top: 0cm;
        }
 </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="cont">
    
    </div>
    </form>
    <script language="javascript" type="text/javascript">
var cont = document.getElementById("cont") ;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
        xmlDoc.async = false;
        xmlDoc.preserveWhiteSpace = true;
        xmlDoc.load("../a1.xml");
        if (xmlDoc.parseError.errorCode != 0) {
           var myErr = xmlDoc.parseError;
           alert("You have error " + myErr.reason);
        } 

        var xslDoc = new ActiveXObject("Msxml2.DOMDocument");
        xslDoc.async = false;

        xslDoc.load("../a1.xsl");
        if (xslDoc.parseError.errorCode != 0) {
           var myErr = xslDoc.parseError;
           alert("You have error " + myErr.reason);
        } 
        var xml = xmlDoc.transformNode(xslDoc);

       cont.innerText =(xml);
        xslDoc = null;
        xmlDoc = null;
        
//操作ＸＭＬ 得到 数据中有数据
var xmlx = new ActiveXObject("Msxml2.DOMDocument");
    xmlx.async = false;
    xmlx.load("../ads.xml");
 var tt  =  xmlx.getElementsByTagName("ImageUrl").item(0).firstChild.text;//得到第一个节点中的数据
     //xmlx.getElementsByTagName("ImageUrl").item(0).childNodes[0].data;
    //  xmlx.getElementsByTagName("ImageUrl").item(0).childNodes[0].nodeValue;
       cont.innerText+="得到的ＸＭＬ节点的数所\r"+tt;
    ttt = xmlx.getElementsByTagName("keyword").item(0).childNodes[0].nodeValue;// 得到CCODE里的值
    //xmlx.getElementsByTagName("keyword").item(0).text;
   // xmlx.getElementsByTagName("keyword").item(0).childNodes[0].data;
    alert(ttt);
    
//操作ＸＭＬ 得到 属性中 数据中有数据   
var xxml = new ActiveXObject("Msxml2.DOMDocument");
    xxml.async = false;
    xxml.load("../GetIdValue.xml");
var idv = xxml.getElementsByTagName('W')[0].getAttribute('Text');
      cont.innerText+="得到的ＸＭＬ属性中  数据<br/>"+idv;
    
    </script>
    
    
    <div>
        ddd

    
    </div>
</body>
</html>
